<?php
class textualComponent extends Object {
	
	function remplace_char($str, $char = null, $len = null){
		if(!$char){
			$char = '-';
		}
		$str = strtolower($str);
		$str = preg_replace('`[áàâäãÃÄÂÀ]`', 'a', $str);
		$str = preg_replace('`[éèêëËÉÈÊ]`', 'e', $str);
		$str = preg_replace('`[íìîïIÎÌ]`', 'i', $str);
		$str = preg_replace('`[óòôöõÕÖÔÒ]`', 'o', $str);
		$str = preg_replace('`[úùûüUÛÙ]`', 'u', $str);
		$str = preg_replace('`[ÿŷỳ]`', 'y', $str);
		$str = preg_replace('`[œ]`', 'oe', $str);
		$str = preg_replace('`[ĉ]`', 'c', $str);
		$str = preg_replace('`[ß]`', 'ss', $str);
		$str = preg_replace('`[\s\'\"\\\/\?\.\=\+\&\%]$`', '', $str);
		$str = preg_replace('`[\s\'\"\\\/\?\.\=\+\&\%]`', $char, $str);
		$str = preg_replace('`_+`', $char, $str);	
		$str = preg_replace('`#`', $char, $str);
	
		if(!$len){
			$str = substr($str, 0, $len);
		}
		return $str;
	}
}
?>
